import java.util.Arrays;

public class Test {
    public static String myToString(int[] array){
        String ret = "[";
        for (int i = 0; i < array.length; i++) {
            ret += array[i];
            if(i != array.length - 1){
                ret += ",";
            }
        }
        ret += "]";
        return ret;
    }
    public static void bubbleSort(int[] array){
        for (int i = 0; i < array.length; i++) {
            boolean flag = false;
            for (int j = 0; j < array.length - 1 - i; j++) {
                if(array[j] < array[j+1]){
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                    flag = true;
                }
            }
            if(flag == false){
                return;
            }
        }
    }

    public static void main(String[] args) {
        int[] array = {1,3,10,45,65,7,8};
        bubbleSort(array);
        System.out.println(Arrays.toString(array));
        //System.out.println(myToString(array));
        //System.out.println(Arrays.toString(array));
    }
}